package com.lc.user.express.httpserver;

import com.lc.user.express.model.BankModel;
import com.lc.user.express.model.CityModel;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/4/1.卡类型
 */
@HttpInlet(Net.GET_BANKCARD)
public class GetBankCard extends ZJDBAsyGet<GetBankCard.Info> {


    public GetBankCard(AsyCallBack listener) {
        super(listener);
    }

    @Override
    protected Info parser(JSONObject object) {
        if (object.optInt("message") == 1) {
            Info info = new Info();
            JSONArray array = object.optJSONArray("list");

            if (array != null) {
                for (int i = 0; i < array.length(); i++) {
                    JSONObject jsonObject = array.optJSONObject(i);
                    BankModel model = new BankModel();
                    model.setName(jsonObject.optString("title"));
                    info.dataList.add(model);
                }

            }
            return info;
        }
        return null;
    }

    public static class Info {
        public List<BankModel> dataList = new ArrayList<>();
    }
}
